//
//  CalendarModel.h
//  CarCare
//
//  Created by ileo on 14-8-4.
//  Copyright (c) 2014年 baozun. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "DateModel.h"

#define CALENDARMGR [CalendarMgr sharedInstance]

#define yyyy_MM_dd @"yyyy-MM-dd"
#define yyyy_MM_dd_HH_mm_ss @"yyyy-MM-dd HH:mm:ss"
#define yyyy_MM_dd_HH_mm @"yyyy-MM-dd HH:mm"

@interface CalendarMgr : NSObject

DEF_SINGLETON

@property (nonatomic, readonly) NSInteger year;
@property (nonatomic, readonly) NSInteger month;
@property (nonatomic, readonly) NSInteger day;

-(NSInteger)yearWithDate:(NSDate *)date;
-(NSInteger)monthWithDate:(NSDate *)date;
-(NSInteger)dayWithDate:(NSDate *)date;

-(NSInteger)currentMonthDays;
-(NSDate *)dateWithStr:(NSString *)dateStr format:(NSString *)format;
-(NSString *)dateStrWithDate:(NSDate *)date format:(NSString *)format;

-(NSTimeInterval)timeIntervalWith_yyyy_MM_dd_Str:(NSString *)dateStr;

+(NSDate *)dateFromDate:(NSDate *)date afterDays:(NSInteger)days;
+(NSDate *)dateFromDate:(NSDate *)date beforeDays:(NSInteger)days;

-(NSString *)currentDay;
-(NSString *)nextDay;
-(NSString *)beforeDay;

-(NSInteger)daysInYear:(NSInteger)year month:(NSInteger)month;//这个月多少天

-(NSArray *)datesDayFrom:(NSDate *)from to:(NSDate *)to;//YYYY-MM-dd
-(NSArray *)datesMonthFrom:(NSDate *)from to:(NSDate *)to;//YYYY-MM


#pragma mark - month
@property (nonatomic, strong) DateModel *today;//今天

-(BOOL)dateModel:(DateModel *)a monthIsBeforeThanDateModel:(DateModel *)b;
-(DateModel *)monthBeforeDateModel:(DateModel *)from months:(NSInteger)months;
-(DateModel *)monthAfterDateModel:(DateModel *)from month:(NSInteger)months;
-(DateModel *)monthBeforeDateModel:(DateModel *)from;
-(DateModel *)monthAfterDateModel:(DateModel *)from;


#pragma mark - calendar
+(BOOL)isTodayWithDate:(NSDate *)date;//是否今天
+(BOOL)isSameDayWithDate1:(NSDate *)date1 date2:(NSDate *)date2;//是否同一天
+(BOOL)isSameMonthWithDate1:(NSDate *)date1 date2:(NSDate *)date2;//是否同一个月
+(BOOL)isDate1:(NSDate *)date1 laterThanDate2:(NSDate *)date2;

+(NSDate *)firstDayInWeekForDate:(NSDate *)date;//date的当前周第一天 （周日）
+(NSDate *)firstDayInLastWeekForDate:(NSDate *)date;//上一周
+(NSDate *)firstDayInNextWeekForDate:(NSDate *)date;//下一周

+(NSDate *)firstDayInMonthForDate:(NSDate *)date;//date的当前月第一天 （一号）
+(NSDate *)firstDayInLastMonthForDate:(NSDate *)date;//上一月
+(NSDate *)firstDayInNextMonthForDate:(NSDate *)date;//下一月

+(NSInteger)weeksCountInMonthForDate:(NSDate *)date;//date的当前月的周数
+(NSInteger)daysCountInMonthForDate:(NSDate *)date;//date的当前月的天数
+(NSDateComponents *)componentsWithDate:(NSDate *)date;

//从某天到某天间隔多少天
+(NSInteger)daysFromDate:(NSDate *)fromDate toDate:(NSDate *)toDate;
@end
